

#ifndef __GDT
#  define __GDT

struct __gdt_entry {

    unsigned short limit_low;
    unsigned short base_low;
    unsigned char base_middle;
    unsigned char access;
    unsigned char granularity;
    unsigned char base_high;

} __attribute__((packed));

struct __gdt_info {

  unsigned short limit;
  unsigned int base;

} __attribute__((packed));

/* Used for the upper word flags. */
#  define __GDT_4K_GRAN  (1 << 7)
#  define __GDT_32BIT    (1 << 6)

/* Used for the lower word flags. */
#  define __GDT_PRESENT  (1 << 7)
#  define __GDT_TYPE     (1 << 4)

/* The type of the segment. */
#  define __GDT_CODE_RW  0xA
#  define __GDT_DATA_RW  0x2


void _gdt_make_gdt_entry(struct __gdt_entry *entry, unsigned short limit_low,
			 unsigned short base_low, unsigned char base_middle,
			 unsigned char access, unsigned char granularity,
		    unsigned char base_high);
void _gdt_make_basic_gdt();
void _gdt_print_gdt_desc(unsigned int);
void _flush_gdt();
void _gdt_print_gdtr();


#endif
